﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Topro.Application.Impl
{
    using Dapper;
    using Topro.Application.Interface;
    using Topro.Db;
    using Topro.Entity.Response.ASRSJOB;
    using Topro.Log;
    using Topro.Util;

    public class ASRSJOBServiceImpl: ASRSJOBService
    {
        #region 注入
        /// <summary>
        /// 
        /// </summary>
        private readonly IUId _uid;

        /// <summary>
        /// db
        /// </summary>
        private readonly IDb _db;

        /// <summary>
        /// loggerService
        /// </summary>
        private readonly LoggerService _loggerService;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dapperFactory"></param>
        /// <param name="logger"></param>
        public ASRSJOBServiceImpl(IDb db, LoggerService loggerService, IUId uid)
        {
            _uid = uid;
            _db = db;
            _loggerService = loggerService;
        }
        #endregion

        /// <summary>
        /// 获取待处理、处理中记录
        /// </summary>
        /// <returns></returns>
        public IEnumerable<ASRSJOBResponse> GetSTATES()
        {
            return _db.DbConnection.Query<ASRSJOBResponse>("select * from asrsjob where STATE IN(0,1)");
        }

        /// <summary>
        /// 获取待处理、处理中记录
        /// </summary>
        /// <returns></returns>
        public ASRSJOBResponse GetByContainerCode(string containerCode)
        {
            return _db.DbConnection.Query<ASRSJOBResponse>("select * from asrsjob where STATE=0 and CTNCODE=@ContainerCode", new { ContainerCode = containerCode }).FirstOrDefault();
        }
    }
}
